﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Windows.Controls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using DataGridApplication.ScrumMagicDataSetTableAdapters;

namespace DataGridApplication
{
  /// <summary>
  /// Interaction logic for Window1.xaml
  /// </summary>
  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
      // ------- F I R S T   M A N N E R --------------
      SqlConnection connection =
        new SqlConnection(ConfigurationManager.ConnectionStrings["DataGridApplication.Properties.Settings.ScrumMagicConnectionString"].ConnectionString);
      SqlCommand com = connection.CreateCommand();
      com.CommandText = "SELECT * FROM Task";
      com.CommandType = System.Data.CommandType.Text;
      SqlDataAdapter adapter = new SqlDataAdapter(com);
      DataTable table = new DataTable();
      adapter.Fill(table);
      dataGrid.ItemsSource = table.DefaultView;

      // ------- S E C O N D   M A N N E R --------------
      //ScrumMagicDataSet dataset = new ScrumMagicDataSet();

      //TaskTableAdapter adapter = new TaskTableAdapter();
      //adapter.Fill(dataset.Task);

      //this.DataContext = dataset.Task.DefaultView;
    }
  }
}
